home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************************
- *
- *
- * ObjectMacZapp -- a standard Mac OOP application template
- *
- *
- *
- * ZApplication.h -- the application object
- *
- *
- *
- *
- *
- * © 1996, Graham Cox
- *
- *
- *
- *
- *************************************************************************************************/
-
-
- #pragma once
-
- #ifndef __ZAPPLICATION__
- #define __ZAPPLICATION__
-
- #ifndef __ZCOMMANDER__
- #include "ZCommander.h"
- #endif
-
- class ZEventHandler;
- class ZWindow;
- class ZUndoTask;
- class ZPrinter;
- class ZMenuBar;
-
- class ZApplication : public ZCommander
- {
- protected:
-
- Boolean done; // normally FALSE, if set TRUE, will try to quit
- short phase; // current phase
- short appResRefNum; // refnum of application resource file
- ZEventHandler* zEH; // event handler object
- ZWindow* mostRecent; // most recently created window
- Handle shortageFund; // to deal with tight memory, we can release this
- OSType** itsFileTypes; // list of filetypes we can open
- ZUndoTask* curUndoTask; // current undoable task
- ZPrinter* itsPrinter; // printer object for handling print commands
-
- public:
- Boolean memIsShort; // flag memory problem
- Boolean userHasSeenAlert; // TRUE if user has been warned about the memory
-
- ZApplication();
- virtual ~ZApplication();
-
- // initialisation and clean-up
-
- virtual void InitMacZoop( const short numMasterBlocks = 8 );
- virtual void StartUp() {};
- virtual void ShutDown() {};
- virtual void ReadPrefs() {};
-
- // event processing
-
- virtual void Run();
- virtual Boolean Quit();
- virtual void RequestQuit();
- virtual Boolean MemoryShortage( const Size bytesShort );
- virtual void Process1Event();
- virtual void HandleCommand( const long aCmd );
- virtual void HandleCommand( const short menuID, const short itemID );
- virtual void UpdateMenus();
- virtual Boolean GetCurrentEvent( EventRecord* anEvent );
- virtual void HandleAppleEvent( AEEventClass aeClass, AEEventID aeID,
- AppleEvent* aeEvt, AppleEvent* reply );
- virtual void ProcessHLEvent( const EventRecord& theEvt ) {};
-
- // error processing
-
- virtual void HandleError( OSErr theErr );
-
- // window construction
-
- virtual void OpenNewWindow();
- virtual void CloseAll( Boolean closeFloaters = FALSE );
- virtual ZWindow* GetFrontWindow();
- virtual void AboutBox();
-
- // opening files
-
- virtual Boolean PickFile( FSSpec* aFile, OSType* fType );
- virtual void OpenFile( const FSSpec& aFile, const OSType fType );
-
- // extending the file types
-
- virtual void AddFileType( const OSType aType );
-
- // undo task handling
-
- virtual void SetTask( ZUndoTask* aTask );
- virtual void UpdateUndo();
- inline ZUndoTask* GetUndoTask() { return curUndoTask; };
-
- // printer handling
-
- virtual void MakePrinter();
- virtual void DoPageSetup();
- virtual void DoPrint();
- inline ZPrinter* GetPrinter() { return itsPrinter; };
-
- // other inline accessors
-
- inline short GetPhase(){ return phase;};
- inline OSType** GetFileTypeList() { return itsFileTypes; };
- inline short GetClicks();
- inline Boolean InBackground();
- inline ZEventHandler* GetEventHandler() { return zEH; };
-
- virtual void GetName( Str255 appName );
- inline short GetAppRefnum() { return appResRefNum; };
-
- protected:
-
- void InitMacApplication( const short numMasterBlocks );
- virtual void MakeEventHandler();
- virtual void MakeClipboard();
- virtual Boolean CheckCanRun();
- virtual void InitMenuBar();
- virtual void MakeNewWindow();
- virtual void CheckLowMemory();
- };
-
- // possible values of "phase"
-
- enum
- {
- kInitialising,
- kRunning,
- kQuitting
- };
-
- #define kUndoStrIndex 5
- #define kRedoStrIndex 6
- #define kCantUndoStrIndex 7
-
- #define kCantRunAlertID 131
-
- // By default, MacZoop will work like a normal Mac application in that it will open a new
- // "untitled" window at startup if no files are passed to it. If you want to make a "faceless"
- // application, comment IN the following define to suppress the opening of the initial window.
-
- //#define NO_UNTITLED_STARTUP_WINDOW 1
-
- #endif